<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>企业信贷管理系统</title>
    <link rel="stylesheet" type="text/css" href="/static/easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/static/easyui/demo/demo.css">
    <script type="text/javascript" src="/static/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
    <style>
        body {
            margin-right: 0px;
            padding: 0px;
        }

        .fm {
            border-style: solid;
            border-width: 1px;
            border-color: gray;
            padding: 5px;
        }

        .fm td {
            text-align: right;
        }

        .fm tr {
            border-bottom: 1px solid gray;
        }

        .label {
            display: block;
            margin-top: 7px;
            margin-bottom: 7px;
            color: grey;
        }

        .menu {
            list-style: none;
            width: 90%;
            border: 1px hidden;
        }

        .menu li {
            text-align: center;
            height: 20px;
            line-height: 20px;
            margin-top: 3px;
            border: 1px solid black;
        }

        .menu li:hover {
            background-color: #428bca;
            border: 1px solid black;
        }

        .menu a {
            text-decoration: none;
            color: black;
            height: 100%;
            display: block;
            width: 100%;
        }

        .menu-li-selected {
            background-color: #428bca;
            border: 1px solid black;
            color: white;
        }

        #loading-mask {
            width: 100%;
            height: 100%;
            position: absolute;
            background-image: url("/static/img/loading.gif");
            background-repeat: no-repeat;
            background-color: #ffffff;
            background-position: center;
            background-attachment: fixed;
            z-index: 999;
        }

        .man-func :hover {
            color: red;
        }

        .btn-loginOut {
            border: none;
            background: none;
            color: grey;
            font-size: 6pt;
        }

        .btn-loginOut :hover {
            color: red;
        }

        #fm-cp td {
            text-align: left;
            padding-left: 2px;

        }

        .index-func a:hover {
            color: red;
        }

        .index-func input:hover {
            color: red;
            text-decoration: underline;
            cursor: pointer;
        }
    </style>
    <script>
        $(function () {
            setTime();
            hello();
            $("#tt").tabs(
                    'add', {
                        title: '系统首页',
                        selected: true,
                        closable: true,
                        border: false,
                        content: "欢迎使用本系统"
                    }
            );
        });
        function getMenuIllegalIndex(i) {
            var panel = $("#menu").accordion('getPanel', i);
            if(panel!=null){
               return i;
            }else{
               return getMenuIllegalIndex(i-1);
            }
        }
        $(function () {
            loanMenu();
            setInterval("setTime()", 1000)
        });
        function loanMenu() {
            var panels = $("#menu").accordion('panels');
            $.each(panels, function (i, o) {
                var illegalIndex = getMenuIllegalIndex(i);
                $("#menu").accordion('remove', illegalIndex);
            });
            $.ajax({
                url: "/management/module/getMenu?time=" + Math.random(),
                dataType: 'json',
                cache:false,
                async: false,
                success: function (result) {
                    if (result.length == 0) {
                        $.messager.show({
                            title: '提示',
                            msg: '未分配任何权限，请联系管理员'
                        });
                        return
                    }
                    $.each(result, function (i, o) {
                        var subMenu = "<ul class=\"menu\">";
                        $.each(o.child, function (i, o) {
                            subMenu += "<li id=\"" + o.id + "\"><a href=\"#\" onclick=\"linkPage('" + o.id + "','" + o.url + "','" + o.name + "')\">" + o.name + "</a></li>"
                        });
                        subMenu += "</ul>";
                        $('#menu').accordion('add', {
                            title: o.name,
                            selected: false,
                            content: subMenu
                        });
                    });
                    $('#menu').accordion('select', 0); //选择第三个，下标从0开始
                    setTimeout("loadingHide()", 250);
                },
                error: function () {
                    setTimeout("loadingHide()", 250);
                    $.messager.show({
                        title: '提示',
                        msg: '读取菜单失败，请联系管理人员'
                    });
                }
            })
        }
        var tempLi = undefined;
        function linkPage(id, linkPage, moduleName) {
            if (tempLi != undefined) {
                tempLi.removeClass("menu-li-selected");
            }
            $("#" + id).addClass("menu-li-selected");
            tempLi = $("#" + id);
            if ($("#tt").tabs('exists', moduleName)) {
                $("#tt").tabs('select', moduleName);
                return;
            }
            $("#tt").tabs(
                    'add', {
                        title: moduleName,
                        selected: true,
                        closable: true,
                        border: false,
                        content: "<iframe  scrolling=\"no\" src=\"/management" + linkPage + "\" style=\"display: block;margin:0xp,padding:0px;width: 100%;height: 100%;border: 0px solid transparent;\"></iframe>",
                    }
            );
        }
        var tabIndex = 0;
        function onContextMenu(e, title, index) {
            tabIndex = index;
            e.preventDefault();
            $('#mm').menu('show', {
                left: e.pageX,
                top: e.pageY
            });
        }
        function closeThis() {
            $('#tt').tabs('close', tabIndex);
        }
        function closeAll() {
            var titles = new Array
            $("#tt li").each(function (index, obj) {
                //获取所有可关闭的选项卡
                var title = $('#tt').tabs('getTab', index);
                titles.push(title.panel('options').title)
            });
            $.each(titles, function (i, o) {
                $('#tt').tabs('close', o);
            })
        }
        function reloadMenu() {
            loanMenu();
        }
        function loadingHide() {
            $("#loading-mask").css("display", "none");
        }
        function hello() {
            var $helloSpan = $("#hello");
            now = new Date(), hour = now.getHours()
            if (hour < 6) {
                $helloSpan.text("凌晨好！")
            }
            else if (hour < 9) {
                $helloSpan.text("早上好！")
            }
            else if (hour < 12) {
                $helloSpan.text("上午好！")
            }
            else if (hour < 14) {
                $helloSpan.text("中午好！")
            }
            else if (hour < 17) {
                $helloSpan.text("下午好！")
            }
            else if (hour < 19) {
                $helloSpan.text("傍晚好！")
            }
            else if (hour < 22) {
                $helloSpan.text("晚上好！")
            }
            else {
                $helloSpan.text("夜里好！")
            }
        }
        function showChangePwd() {
            $("#dl-cp").dialog('open')
        }
        function cancelChangePwd() {
            $("#tips-cp").hide();
            $("#fm-cp").form("clear");
            $("#dl-cp").dialog('close')

        }
        function doChangePwd() {
            $("#errDetail").text("");
            $('#fm-cp').form('submit', {
                url: "/management/changePwd",
                onSubmit: function () {
                    var wasValidated = true;
                    wasValidated = $('#fm-cp').form('validate');
                    return wasValidated;

                },
                success: function (data) {
                    var resp = eval('(' + data + ')');
                    if (resp.code == '200') {
                        alert('修改密码成功!');
                        $(location).attr('href', '/passport/login');
                    } else {
                        $("#tips-cp").show();
                        $("#errDetail").text(resp.errDetail);
                    }
                }
            });
        }
        $.extend($.fn.validatebox.defaults.rules, {
            equals: {
                validator: function (value, param) {
                    return value == $(param[0]).val();
                },
                message: '两次输入密码不一致'
            }
        });
        $.extend($.fn.validatebox.defaults.rules, {
            minLength: {
                validator: function (value, param) {
                    return value.length >= param[0];
                },
                message: '密码长度不得少于8位'
            },
            pwd: {
                validator: function (value, param) {
                    return /^\w+$/.test(value);
                },
                message: '密码由数字、26个英文字母或者下划线组成'
            }
        });
        function setTime() {
            var date = new Date();  //创建对象
            var y = date.getFullYear();     //获取年份
            var m = date.getMonth() + 1;   //获取月份  返回0-11
            var d = date.getDate(); // 获取日
            var w = date.getDay();   //获取星期几  返回0-6   (0=星期天)
            var ww = ' 星期' + '日一二三四五六'.charAt(new Date().getDay());//星期几
            var h = date.getHours();  //时
            var minute = date.getMinutes();  //分
            var s = date.getSeconds(); //秒
            var sss = date.getMilliseconds(); //毫秒
            if (m < 10) {
                m = "0" + m;
            }
            if (d < 10) {
                d = "0" + d;
            }
            if (h < 10) {
                h = "0" + h;
            }
            if (minute < 10) {
                minute = "0" + minute;
            }
            if (s < 10) {
                s = "0" + s;
            }
            if (sss < 10) {
                sss = "00" + sss;
            } else if (sss < 100) {
                sss = "0" + sss;
            }
            $("#showTime").text(y + "/" + m + "/" + d + "   " + h + ":" + minute + ":" + s + "  " + ww);
        }
    </script>
</head>
<body class="easyui-layout">
<div id="loading-mask"></div>
<div id="mm" class="easyui-menu" style="width:120px;" data-options="hideOnUnhover:false">
    <div onclick="closeThis()" data-options="iconCls:'icon-no'">关闭</div>
    <div class="menu-sep"></div>
    <div onclick="closeAll()" data-options="iconCls:'icon-cancel'">关闭所有</div>
</div>
<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px">
    企业信贷管理系统
    <div class="index-func" style="float:right;margin-left:20px;text-align:right;width:400px">
        <a href="#" style="text-decoration:none;color:grey;margin-left:1px;padding: 0px">${realname}</a>
        ，
        <span id="hello" style="color:grey;"></span>
        <span>丨</span>
        <a class="man-func" href="#" style="text-decoration:none;color:grey;" onclick="showChangePwd()">修改密码</a>
        <span>丨</span>
    <#--<a class = "man-func" href="javascript:loginOut()" style="text-decoration:none;color:blue;">注销</a>-->
        <form method="POST" action="/passport/loginOut" enctype="multipart/form-data" style="display: inline">
            <input class="btn-loginOut" type="submit" value="注销"/>
        </form>
        <div style="color: whitesmoke">
            <span id="showTime"></span>
        </div>
    </div>
</div>
<div id="menu-lt" data-options="tools:[
				{
					iconCls:'icon-reload',
					handler:reloadMenu
				}],region:'west',split:true,title:'功能列表'" style="width:150px;padding:0;">
    <div id="menu" class="easyui-accordion" style="width:100%;height:100%;border: 0">

    </div>
</div>
<div data-options="region:'south',border:false" style="height:50px;background:#B3DFDA;padding:10px;"><span
        style="font-size: 12sp;float: right;display: inline;margin-top: 10px ">贵州中小乾信有限公司</span></div>
<div id="tb" data-options="region:'center'" style="height: 100%;border: 0 solid black !important;">
    <div id="tt" class="easyui-tabs" style="width:100%;height:100%" data-options="onContextMenu:onContextMenu">

    </div>
</div>
<div id="dl-cp" class="easyui-dialog"
     data-options="modal:true,title:'修改密码',
     closed:true,
     width:280,resizable:false,buttons:'#bb'"
     style="text-align: center">
    <form id="fm-cp"
          style="border: 1px solid lightskyblue;padding: 3px;padding: 0;margin: auto;width: 98%;height: 98%;text-align: center">
        <table style="width: 100%;margin: auto" cellpadding="1" cellspacing="1">
            <tr>
                <th style="text-align: center;background:#B3DFDA ">
                    旧密码:
                </th>
                <td>
                    <input name="oldPwd" class="easyui-validatebox" type="password"
                           data-options="required: true,missingMessage:'请输入原密码'"/>
                </td>
            </tr>
            <tr>
                <th style="text-align: center;background:#B3DFDA ">
                    新密码:
                </th>
                <td>
                    <input id="newPwd" name="newPwd" class="easyui-validatebox" type="password"
                           data-options="missingMessage:'请输入新密码',required: true,validType:['minLength[8]','pwd']"/>
                </td>
            </tr>
            <tr>
                <th style="text-align: center;background:#B3DFDA ">
                    确认密码:
                </th>
                <td>
                    <input id="confirmNewPwd" name="confirmNewPwd" class="easyui-validatebox" type="password"
                           data-options="invalidMessage:'两次输入密码不一致',missingMessage:'请再次输入新密码',required: true"
                           validType="equals['#newPwd']">
                </td>
            </tr>
            <tr id="tips-cp" style="display: none;">
                <td colspan="2">
                    <span id="errDetail" style="color: red"></span>
                </td>
            </tr>
        </table>
    </form>
    <div id="bb">
        <a href="#" onclick="doChangePwd()" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
        <a href="#" on onclick="cancelChangePwd()" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">取消</a>
    </div>
</div>
</body>
</html>